﻿using System.ComponentModel.DataAnnotations;
using Tanmia.Basis.Core;

namespace Tanmia.Warehouse.Core
{
    /// <summary>
    /// المستودع
    /// </summary>
    public partial class Section : BaseBusinessObject
    {
        public const string HeadName = "<رئيسي>";
        public static readonly Section HeadItem = new Section { sectionID = -1, name = HeadName, engName = "<Main>" };

        private int sectionID;
        private SectionType sectionType;
        private Branch branch;
        private string name;
        private string engName;
        private string abbreviation;
        private string notes;
        private Section parent;

        /// <summary>
        /// رقم تعريف المستودع
        /// </summary>
        [Display(Name = "رقم المستودع: ", ShortName = "رقم المستودع", Order = 0, AutoGenerateField = true)]
        public virtual int SectionID
        {
            get { return sectionID; }
            set { SetValue<int>("SectionID", ref  sectionID, value); }
        }

        [Display(Name = "نوع القسم: ", AutoGenerateField = false)]
        public virtual SectionType SectionType
        {
            get { return sectionType; }
            set { SetValue<SectionType>("SectionType", ref sectionType, value); }
        }

        [Display(Name = "الفرع: ", AutoGenerateField = false)]
        public virtual Branch Branch
        {
            get { return branch; }
            set { SetValue<Branch>("Branch", ref branch, value); }
        }

        [Display(Name = "الاسم: ", ShortName = "الاسم", Order = 3, AutoGenerateField = true)]
        public virtual string Name
        {
            get { return name; }
            set { SetValue<string>("Name", ref name, value); }
        }

        /// <summary>
        /// اسم المستودع باللغة الإنكليزية
        /// </summary>
        [Display(Name = "الأسم الأجنبي: ", ShortName = "الاسم الأجنبي", Order = 4, AutoGenerateField = true)]
        public virtual string EngName
        {
            get { return engName; }
            set { SetValue<string>("EngName", ref engName, value); }
        }

        [Display(Name = "الإختصار: ", ShortName = "الإختصار", Order = 5, AutoGenerateField = true)]
        public virtual string Abbreviation
        {
            get { return abbreviation; }
            set { SetValue<string>("Abbreviation", ref abbreviation, value); }
        }

        /// <summary>
        /// ملاحظات
        /// </summary>
        [Display(Name = "ملاحظات: ", ShortName = "ملاحظات", Order = 6, AutoGenerateField = true)]
        public virtual string Notes
        {
            get { return notes; }
            set { SetValue<string>("Notes", ref notes, value); }
        }

        /// <summary>
        /// الفرع الذي يتبع له المستودع الحالي
        /// </summary>
        [Display(Name = "التابع لـ: ", AutoGenerateField = false)]
        public virtual Section Parent
        {
            get { return parent; }
            set { SetValue<Section>("Parent", ref parent, value); }
        }

        public override bool Equals(object obj)
        {
            if (!base.Equals(obj)) return false;

            return ((Section)obj).SectionID == this.SectionID;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }
}
